import { GiftBagInfo } from "../model/GiftBagInfo";
import { EReward } from "../../../Message/Public/EReward";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
type int = number;
//class RandomGiftBagConfig
    
    export  class RandomGiftBagConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            if (RandomGiftBagConfig._instance != null) 
            {
                throw new Error(" ResConfig 单例 ");
            }
            this.init();
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=0;
            var loc6=0;
            var loc7=null;
            var loc8=0;
            var loc9=arg1;
            for(loc7 of loc9) 
            {
                loc1 = [];
                loc3 = String(loc7.itemList).split("#");
                loc5 = 0;
                loc6 = loc3.length;
                while (loc5 < loc6) 
                {
                    loc4 = String(loc3[loc5]).split(",");
                    loc2 = new GiftBagInfo();
                    loc2.type = EReward._ERewardItem;
                    loc2.num = loc4[1];
                    loc2.code = loc4[2];
                    loc2.career = loc4[3];
                    if (loc2.code != 0) 
                    {
                        loc1.push(loc2);
                    }
                    ++loc5;
                }
                this._map[loc7.code] = loc1;
            }
            return;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_random_gift_bag.json");
            this.write(loc1);
            return;
        }

        public getInfoByType(arg1: int): Array<any>
        {
            return this._map[arg1];
        }

        public static get instance(): RandomGiftBagConfig
        {
            if (RandomGiftBagConfig._instance == null) 
            {
                RandomGiftBagConfig._instance = new RandomGiftBagConfig();
            }
            return RandomGiftBagConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: RandomGiftBagConfig;
    }
